package com.gljx.web.controller;

/**
 * Created by Administrator on 2017/11/7 0007.
 */

import com.gljx.util.*;
import com.gljx.web.Entity.*;
import com.gljx.web.dao.RecordinMapper;
import com.gljx.web.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @Author lcx
 * @Date 2017/11/7 0007 上午 8:56
 * 档案管理
 */
@Controller
@RequestMapping("/")
public class RecordinController {

    @Autowired
    RecordinService recordinService;

    @Autowired
    RecordinentryService recordinentryService;

    @Autowired
    DepartmentService departmentService;

    @Autowired
    CustomLogService customLogService;

    @Autowired
    StudentService studentService;
    @Autowired
    RecordinMapper recordinMapper;
    @Autowired
    StudentController studentController;
    @Autowired
    MakeupChargeEntryService makeupChargeEntryService;
    @Autowired
    HttpSession session;

    /**
     * @Author lcx
     * @Date 2017/11/7 0007 上午 9:10
     * 查询档案列表
     */
    @RequestMapping("/queryRecordin/look.action")
    public String queryRecordin(HttpServletRequest request,
                                @RequestParam(value = "fnumber", defaultValue = "") String fnumber
            , @RequestParam(value = "name", defaultValue = "") String name
            , @RequestParam(value = "beginTime", defaultValue = "") String beginTime
            , @RequestParam(value = "endTime", defaultValue = "") String endTime
            , @RequestParam(value = "state", defaultValue = "") String state
            , @RequestParam(value = "alertType", defaultValue = "") String alertType) {

        PageBean<Recordin> pb = new PageBean<>();
        //获取操作人信息
        User user = (User) request.getSession().getAttribute("user");
        List<Recordin> recordinList = new ArrayList<>();
        try {
            fnumber = fnumber == null ? "" : fnumber.trim();//去空格
            name = name == null ? "" : name.trim();//去空格
            //第一次进来
            if ("first".equals(state)) {
                beginTime = TimeFormat.getMonth();
                endTime = TimeFormat.getNowTime();
                pb = getPageBean(request, user.getFcompanyid(), fnumber, name, beginTime, endTime, "");
            } else if ("".equals(state) && "".equals(beginTime) || "".equals(endTime)) {
                pb = getPageBean(request, user.getFcompanyid(), fnumber, name, beginTime, endTime, null);

            } else {
                pb = getPageBean(request, user.getFcompanyid(), fnumber, name, beginTime, endTime, "");

            }

            //获取当前分页的值
            recordinList = pb.getBeanList();

            //把获取到的数据传回页面
            for (Recordin recordin : recordinList) {
                //查询学员信息
                recordin.setRecordinentryList(recordinentryService.selectRecordinentryByFid(recordin.getFid(), name));
            }

            request.setAttribute("fnumber", fnumber);
            request.setAttribute("name", name);
            request.setAttribute("beginTime", beginTime);
            request.setAttribute("endTime", endTime);
            request.setAttribute("recordinList", recordinList);
            request.setAttribute("pb", pb);
            request.setAttribute("alertType", alertType);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return "/backHome/recordinAdmin/selRecordin/RecordinList";
    }

    /**
     * 返回PageBean实体类  包括记录总数，页码，每页记录集等  dmz 20160921
     *
     * @return 返回PageBean实体类
     * @throws Exception
     * @author Joshua Bloch
     * @since 1.5
     */
    public PageBean<Recordin> getPageBean(HttpServletRequest request, String companyId, String fnumber,
                                          String name, String beginTime, String endTime,
                                          String state) throws Exception {

        int offset;//从第几条数据开始加载
        if (request.getParameter("pager.offset") == null) {
            offset = 0;
        } else {
            offset = Integer.parseInt(request.getParameter("pager.offset"));
        }
        //拼接SQL语句
        StringBuffer psql = new StringBuffer();
        //
        if (state == null) {

            psql.append("SELECT DISTINCT R.fid, R.FNUMBER, TO_CHAR(R.FBIZDATE, 'YYYY-MM-DD') FBIZDATE, R.FDESCRIPTION, E.NAME AS checkName, U.NAME AS createName, CFBILLSTATE, r.FCREATETIME " +
                    " FROM CT_DS_RECORDIN R LEFT JOIN T_E_USER E ON R.FAUDITORID = E.FID " +
                    " left join ct_ds_recordinentry r2 on r.fid = r2.FPARENTID" +
                    "  LEFT JOIN CT_DS_STUDENT S ON R2.CFSTUDENTID = S.FID" +
                    " LEFT JOIN T_E_USER U ON R.FCREATORID = U.FID ");
            psql.append(" where R.FCONTROLUNITID= '" + companyId + "'");
            if (!"".equals(fnumber) && fnumber != null) {
                psql.append(" and R.FNUMBER like '%" + fnumber + "%' ");
            }
            if (!"".equals(name) && name != null) {
                psql.append(" and s.FNAME_L2 LIKE '%" + name + "%' ");
            }
            psql.append(" ORDER BY r.FCREATETIME DESC");

        } else {

            psql.append("SELECT DISTINCT R.fid, R.FNUMBER, TO_CHAR(R.FBIZDATE, 'YYYY-MM-DD') FBIZDATE, R.FDESCRIPTION, E.NAME AS checkName, U.NAME AS createName, CFBILLSTATE, r.FCREATETIME " +
                    " FROM CT_DS_RECORDIN R LEFT JOIN T_E_USER E ON R.FAUDITORID = E.FID " +
                    " left join ct_ds_recordinentry r2 on r.fid = r2.FPARENTID" +
                    "  LEFT JOIN CT_DS_STUDENT S ON R2.CFSTUDENTID = S.FID" +
                    " LEFT JOIN T_E_USER U ON R.FCREATORID = U.FID ");
            psql.append(" where R.FCONTROLUNITID= '" + companyId + "'");
            if (!"".equals(fnumber) && fnumber != null) {
                psql.append(" and R.FNUMBER like '%" + fnumber + "%' ");
            }
            if (!"".equals(name) && name != null) {
                psql.append(" and s.FNAME_L2 LIKE '%" + name + "%' ");
            }
            psql.append(" and  (r.FBIZDATE BETWEEN to_date('" + beginTime + "', 'YYYY/MM/DD') AND to_date('" + endTime + "', 'YYYY/MM/DD')) " +
                    " ORDER BY r.FCREATETIME DESC");

        }

        int psize = 50; //每页显示数
        int pindex = offset / psize;//+1  页码从0开始
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap = recordinService.selectPage(pindex, psql.toString(), psize);
        PageBean<Recordin> pb = new PageBean<>();
        pb.setPc(pindex); //页码
        Map<String, Object> paramMapCount = getPageBeanCount(psql.toString()); //取记录总数
        pb.setTr((int) paramMapCount.get("Pcount")); //记录总数
        pb.setPs(psize);
        pb.setBeanList((List<Recordin>) paramMap.get("v_cur")); //每页数据集
        return pb;
    }

    //查询学生
    public PageBean<Student> getPageBean2(HttpServletRequest request, String fid) throws Exception {

        int offset;//从第几条数据开始加载
        if (request.getParameter("pager.offset") == null) {
            offset = 0;
        } else {
            offset = Integer.parseInt(request.getParameter("pager.offset"));
        }
        String psql = "SELECT S.fid,S.FNAME_L2,S.fnumber,S.FSIMPLENAME,S.FDESCRIPTION_L2," +
                /*"  TO_CHAR(S.FCREATETIME, 'YYYY-MM-DD HH:MI:SS') FCREATETIME," +*/
                " u.NAME createName," +
                "  TO_CHAR(S.FLASTUPDATETIME, 'YYYY-MM-DD HH:MI:SS') FLASTUPDATETIME," +
                "  N.NAME updateName,A.FNAME_L2 FCONTROLUNITID,S.CFIDCARDNO ,TO_CHAR(S.CFBIRTHDAY, 'YYYY-MM-DD') CFBIRTHDAY," +
                "  S.CFADDRESS,S.CFLINKADDRESS,S.CFSJHM,S.CFLXDH,S.CFSLLX,S.CFXZJCXDH, " +
                "  S.CFSLZJCXDH,TO_CHAR(S.FCREATETIME, 'YYYY-MM-DD') FCREATETIME " +
                " FROM CT_DS_STUDENT S " +
                "  LEFT JOIN T_E_USER U ON s.FCREATORID = U.FID " +
                "  LEFT JOIN T_E_USER N ON s.FLASTUPDATEUSERID = N.FID " +
                "  LEFT JOIN CT_DS_ADMIN A ON s.FCONTROLUNITID = a.FID ";
        int psize = 15; //每页显示数
        int pindex = offset / psize;//+1  页码从0开始
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap = studentService.selectPage(pindex, psql, psize);
        PageBean<Student> pb = new PageBean<>();
        pb.setPc(pindex); //页码
        Map<String, Object> paramMapCount = getPageBeanCount(psql); //取记录总数
        pb.setTr((int) paramMapCount.get("Pcount")); //记录总数
        pb.setPs(psize);
        pb.setBeanList((List<Student>) paramMap.get("v_cur")); //每页数据集
        return pb;

    }

    /**
     * 取记录总数 dmz 20160921
     *
     * @param psql SQL语句
     * @return Map
     * @throws Exception
     */
    public Map<String, Object> getPageBeanCount(String psql) throws Exception {

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap = recordinService.selectPageCount(psql);
        return paramMap;
    }

    /**
     * @Author lcx
     * @Date 2017/11/9 0009 下午 2:12
     * 跳转到添加页面
     */
    @RequestMapping(value = "/go_add_Recordin")
    public String goAddRecordin(HttpServletRequest request, String alertType) throws Exception {
        //获取操作人信息
        User user = (User) request.getSession().getAttribute("user");
        Department department = departmentService.queryAdminByFid(user.getFcompanyid());

        /*String number = customLogService.selectFunmber("CT_DS_RECORDIN", user.getFcompanyid());*/
        String fnumber = GetFnumber.fnumbers("DARK");

        Calendar ca = Calendar.getInstance();// 得到一个Calendar的实例
        ca.setTime(new Date()); // 设置时间为当前时间
        ca.add(Calendar.MONTH, -3);// 月份减1
        Date resultDate = ca.getTime(); // 结果
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String beginTime = sdf.format(resultDate);
        String endTime = sdf.format(new Date());

        Map map = studentController.getPageBean2(request, "", "", "0", beginTime, endTime);

        request.setAttribute("beginTime", beginTime);
        request.setAttribute("endTime", endTime);
        request.setAttribute("fbizdate", TimeFormat.getNowTime());

        request.setAttribute("createName", user.getName());
        request.setAttribute("fnumber", fnumber);
        request.setAttribute("department", department.getFnameL2());
        request.setAttribute("pb", map.get("pb"));
        request.setAttribute("students", map.get("sList"));

        request.setAttribute("alertType", alertType);

        return "/backHome/recordinAdmin/selRecordin/RecordinAdd";
    }

    @RequestMapping(value = "go_update_recordin")
    public String goUpdateRecordin(HttpServletRequest request, String fid, String xqid) throws Exception {

        //获取操作人信息
        User user = (User) request.getSession().getAttribute("user");
        Department department = departmentService.queryAdminByFid(user.getFcompanyid());

        //根据fid查询
        Recordin recordin = recordinService.selectRecordinByFid(fid);
        List<Recordinentry> recordinentryList = recordinentryService.selectRecordinentryByFid(fid, "");

        Calendar ca = Calendar.getInstance();// 得到一个Calendar的实例
        ca.setTime(new Date()); // 设置时间为当前时间
        ca.add(Calendar.MONTH, -3);// 月份减1
        Date resultDate = ca.getTime(); // 结果
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String beginTime = sdf.format(resultDate);
        String endTime = sdf.format(new Date());

        Map map = studentController.getPageBean2(request, "", "", "0", beginTime, endTime);

        //查询是否是经办人
        Axamine axamine = new Axamine();
        request.setAttribute("AuditState", axamine.selectAuditPerson(recordin.getFnumber()));

        request.setAttribute("beginTime", beginTime);
        request.setAttribute("endTime", endTime);

        request.setAttribute("pb", map.get("pb"));
        request.setAttribute("students", map.get("sList"));
        request.setAttribute("department", department.getFnameL2());
        request.setAttribute("recordin", recordin);
        request.setAttribute("recordinentryList", recordinentryList);

        return "/backHome/recordinAdmin/selRecordin/updateRecordin";
    }

    /**
     * @Author lcx
     * @Date 2017/11/8 0008 下午 3:47
     * 更新数据
     */
    @RequestMapping(value = "/update_recordin")
    public String updateRecordin(HttpServletRequest request, Recordin recordin) {

        Axamine axamine = new Axamine();

        String[] rfid = request.getParameterValues("rfid");
        String[] rfseq = request.getParameterValues("rfseq");
        String[] rstuname = request.getParameterValues("rstuname");
        String[] rcfstudentno = request.getParameterValues("rcfstudentno");
        String[] rcfidcardno = request.getParameterValues("rcfidcardno");
        String[] rcfcartype = request.getParameterValues("rcfcartype");
        String[] rcfsjhm = request.getParameterValues("rcfsjhm");
        String[] rcfsex = request.getParameterValues("rcfsex");
        String[] rcfcfwz = request.getParameterValues("rcfcfwz");
        String[] rcfjyzbh = request.getParameterValues("rcfjyzbh");
        String[] rcfremark = request.getParameterValues("rcfremark");
        Recordin recordintem = recordinMapper.selectByPrimaryKey(recordin.getFid());

        recordin.setFcreatorid(recordintem.getFcreatorid());
        recordin.setFcreatetime(recordintem.getFcreatetime());
        //获取操作人信息
        User user = (User) request.getSession().getAttribute("user");
        //公司id
        recordin.setCfficompanyid(user.getFcompanyid());
        //控制单元id
        recordin.setFcontrolunitid(user.getFcompanyid());
        //获取当前修改时间
        String updateTime = TimeFormat.timeFormat(new Date());
        //修改时间
        recordin.setFlastupdatetime(updateTime);
        //修改人id
        recordin.setFlastupdateuserid(user.getFid());

        //删除
        recordinService.deleteRecordinAndRecordintentry(recordin.getFid());

        String uuid = GetFid.UUIDIntoFid();
        recordin.setFid(uuid);

        //为了消除提交页面点击确定丢失审核人的 问题
        if ("2".equals(recordin.getFfivouchered() + "")) {
            recordin.setFauditorid(recordintem.getFauditorid());
            recordin.setCfbillstate(Long.valueOf("3"));
        }

        for (int i = 0; i < rfid.length; i++) {
            Recordinentry recordinentry = new Recordinentry();
            recordinentry.setFid(GetFid.UUIDIntoFid());
            recordinentry.setFparentid(uuid);
            /*recordinentry.setStuname(rstuname[i]);*/ //界面传入的的姓名
            recordinentry.setCfstudentid(rstuname[i]);
            recordinentry.setCfstudentno(rcfstudentno[i]);
            recordinentry.setCfidcardno(rcfidcardno[i]);
            recordinentry.setCfcartype(rcfcartype[i]);
            recordinentry.setCfsjhm(rcfsjhm[i]);
            recordinentry.setCfjyzbh(rcfjyzbh[i]);
            recordinentry.setCfcfwz(rcfcfwz[i]);
            recordinentry.setCfjyzbh(rcfjyzbh[i]);
            recordinentry.setCfremark(rcfremark[i]);

            recordinentryService.addRecordinentry(recordinentry);
        }
        //更新数据操作
        recordinService.addRecordin(recordin);
        //添加日志
        customLogService.addLog("档案管理", TimeFormat.timeFormat(new Date()) + "对档案入库进行更新", null, user.getFid());


        return "redirect:/DrivingSys/queryRecordin/look.action?state=first&alertType=qd";
    }

    /**
     * @Author lcx
     * @Date 2017/11/11 0011 上午 8:44
     */
    @RequestMapping(value = "/add_recordin")
    public String addRecordin(HttpServletRequest request, Recordin recordin) {

        String[] rfid = request.getParameterValues("rfid");
        String[] rfseq = request.getParameterValues("rfseq");
        String[] rstuname = request.getParameterValues("rstuname");
        String[] rcfstudentno = request.getParameterValues("rcfstudentno");
        String[] rcfidcardno = request.getParameterValues("rcfidcardno");
        String[] rcfcartype = request.getParameterValues("rcfcartype");
        String[] rcfsjhm = request.getParameterValues("rcfsjhm");
        String[] rcfsex = request.getParameterValues("rcfsex");
        String[] rcfcfwz = request.getParameterValues("rcfcfwz");
        String[] rcfjyzbh = request.getParameterValues("rcfjyzbh");
        String[] rcfremark = request.getParameterValues("rcfremark");

        /*获取uuid*/
        String uuid = GetFid.UUIDIntoFid();
        //获取操作人信息
        User user = (User) request.getSession().getAttribute("user");
        recordin.setFid(uuid);
        //公司id
        recordin.setCfficompanyid(user.getFcompanyid());
        //控制单元id
        recordin.setFcontrolunitid(user.getFcompanyid());
        //获取当前修改时间
        String createTime = TimeFormat.timeFormat(new Date());
        //修改时间
        recordin.setFcreatetime(createTime);
        //修改人id
        recordin.setFcreatorid(user.getFid());

        if (rfid != null) {
            for (int i = 0; i < rfid.length; i++) {
                Recordinentry recordinentry = new Recordinentry();
                recordinentry.setFid(GetFid.UUIDIntoFid());
                recordinentry.setFparentid(uuid);
                recordinentry.setCfsex(Long.valueOf(rcfsex[i]));
                //recordinentry.setStuname(rstuname[i]); //界面传入的的姓名
                recordinentry.setCfstudentid(rstuname[i]);
                recordinentry.setCfstudentno(rcfstudentno[i]);
                recordinentry.setCfidcardno(rcfidcardno[i]);
                recordinentry.setCfcartype(rcfcartype[i]);
                recordinentry.setCfsjhm(rcfsjhm[i]);
                recordinentry.setCfjyzbh(rcfjyzbh[i]);
                recordinentry.setCfcfwz(rcfcfwz[i]);
                recordinentry.setCfjyzbh(rcfjyzbh[i]);
                recordinentry.setCfremark(rcfremark[i]);

                recordinentryService.addRecordinentry(recordinentry);
            }
        }
        //更新数据操作
        recordinService.addRecordin(recordin);


        //添加日志
        customLogService.addLog("档案管理", TimeFormat.timeFormat(new Date()) + "对档案入库进行新增", null, user.getFid());


        return "redirect:/DrivingSys/go_add_Recordin";
    }

    /**
     * @Author lcx
     * @Date 2017/11/10 0010 下午 5:08
     * 通过ajax传入参数fid查询学生姓名
     */
    @RequestMapping(value = "/selStudentsByFid")
    @ResponseBody
    public Object selPositiongradeById(@RequestParam(value = "id", required = false) String id) throws Exception {
        List<Student> studentsNameList = new ArrayList<Student>();
        String[] ids = id.split(",");
        for (int i = 0; i < ids.length; i++) {
            Student student = recordinentryService.selectStudentById(ids[i]);
            studentsNameList.add(student);
        }
        Map<String, List<Student>> studentsList = new HashMap<>();
        studentsList.put("studentsNameList", studentsNameList);
        return studentsList;
    }

    /**
     * @Author lcx
     * @Date 2018/3/19 0019 上午 9:28
     * 根据学生id 以及练车时间 以及科目查询 练车预约中 同车的人
     */
    @RequestMapping(value = "/selStudentsByFidAsCar")
    @ResponseBody
    public Object selStudentsByFidAsCar(@RequestParam(value = "id", required = false) String id,
                                        @RequestParam(value = "cflcsjid", defaultValue = "") String cflcsjid,
                                        @RequestParam(value = "kemu", defaultValue = "2") String kemu) throws Exception {
        List<Student> student = recordinentryService.selectStudentByIdAsCflcsjidAndKemu(id, cflcsjid, kemu);
        Map<String, List<Student>> studentsList = new HashMap<>();
        studentsList.put("studentsNameList", student);
        return studentsList;
    }

    /**
     * @Author lcx
     * @Date 2018/1/24 0024 上午 10:56
     * 之前写错的方法 请不要调用 会查询出科目二三分车教练的内容
     */
    @RequestMapping(value = "/selStudentsByFidmakeupCharge")
    @ResponseBody
    public Object selPositiongradeByIdmakeupCharge(@RequestParam(value = "id", required = false) String id,
                                                   @RequestParam(value = "cfbilltype") String cfbilltype) throws Exception {
        List<Student> studentsNameList = new ArrayList<Student>();
        String[] ids = id.split(",");
        for (int i = 0; i < ids.length; i++) {
            Student student = recordinentryService.selectStudentByIdAsCfbilltype(ids[i], cfbilltype).get(0);
            studentsNameList.add(student);
            //查询学生的 交补考费次数: 交补考费总额:
            List<MakeupChargeEntry> makeupChargeEntry = makeupChargeEntryService.selectCfkscsAndCfysje(student.getFid());
            int money = 0;
            for (MakeupChargeEntry tem : makeupChargeEntry) {
                money += tem.getCfysje().intValue();
            }
            student.setCfjbkcs(String.valueOf(makeupChargeEntry.size()));//补交考试次数
            student.setCfjbkfje(String.valueOf(money));
        }
        session.setAttribute("fid",id);
        Map<String, List<Student>> studentsList = new HashMap<>();
        studentsList.put("studentsNameList", studentsNameList);
        return studentsList;
    }

/*
    @RequestMapping(value = "/selStudentByName")
    @ResponseBody
    public Object selStudentByName(HttpServletRequest request, @RequestParam(value = "name", required = false) String name) throws Exception {
        //获取session中的登录信息
        User user = (User) request.getSession().getAttribute("user");
        List<Student> studentArrayList = new ArrayList<Student>();
        Map<String, List<Student>> stu = new HashMap();
        name = name.trim();//去空格
        if (name != null && !name.equals("")) {
            studentArrayList = studentService.selectStudentByCfidcardno(name);
            stu.put("sList", studentArrayList);
        } else {
            Department department = departmentService.queryAdminByFid(user.getFcompanyid());   //获取登录用户组织ID
            PageBean<Student> pBean = getPageBean2(request, department.getFid());        //分页数据
            List<Student> sList = pBean.getBeanList();
            request.setAttribute("sList", sList);
            request.setAttribute("pb", pBean);
            stu.put("sList", sList);
        }

        return stu;
    }*/

    /**
     * @Author lcx
     * @Date 2017/11/2 0002 下午 4:28
     * 对财务基础资料删除
     */
    @RequestMapping(value = "delete_recordin")
    public String deleteRecordin(HttpServletRequest request, String[] deleteId, String[] fnumber) throws Exception {

        User user = (User) request.getSession().getAttribute("user");
        /*删除 子类也删除*/
        recordinService.deleteByRecordinKey(deleteId, fnumber);

        //添加日志
        customLogService.addLog("档案管理", TimeFormat.timeFormat(new Date()) + "对档案入库进行删除", null, user.getFid());

        return "redirect:/DrivingSys/queryRecordin/look.action?state=first";
    }

    /**
     * @Author lcx
     * @Date 2018/2/5 0005 上午 10:20
     * 档案入库流程审核
     */
    @RequestMapping(value = "/queryRecordinExamine")
    @ResponseBody
    public ServerResponse examine(HttpServletRequest request, @RequestParam(defaultValue = "", value = "fid") String fid,
                                  @RequestParam(defaultValue = "", value = "state") String state,
                                  @RequestParam(defaultValue = "", value = "agreed") String agreed,
                                  @RequestParam(defaultValue = "", value = "auditcomment") String auditcomment,
                                  @RequestParam(defaultValue = "", value = "fnumber") String fnumber,
                                  @RequestParam(defaultValue = "", value = "rcfcfwz[]") String[] rcfcfwz,//结业时间 - -存放位置
                                  @RequestParam(defaultValue = "", value = "rcfjyzbh[]") String[] rcfjyzbh,//结业证编号  - -结业证编号  对应学生表中内容
                                  @RequestParam(defaultValue = "", value = "rcfremark[]") String[] rcfremark//发证时间 - -备注
    ) {
        Recordin recordin = new Recordin();


        recordin.setFid(fid);
        recordin.setFnumber(fnumber);

        return recordinService.examine(recordin, state, agreed, auditcomment, rcfcfwz, rcfjyzbh, rcfremark);
    }

    /**
     * @Author lcx
     * @Date 2018/2/27 0027 上午 11:49
     * 提交
     */
    @RequestMapping(value = "/queryRecordinSubmit")
    @ResponseBody
    public ServerResponse submit(HttpServletRequest request,
                                 @RequestParam(defaultValue = "", value = "fnumber") String fnumber,
                                 @RequestParam(defaultValue = "", value = "fid") String fid) {
        Axamine axamine = new Axamine();
        Recordin recordin = new Recordin();

        recordin.setFid(fid);
        /*recordin.setFauditorid(((User) request.getSession().getAttribute("user")).getFid());*/
        recordin.setCfbillstate(Long.valueOf("4"));
        recordinMapper.updateByPrimaryKeySelective(recordin);
        return axamine.submissionProcess(String.valueOf(fnumber));
    }

    @RequestMapping("/queryRecordinXls")
    public String queryRecordinXls(HttpServletRequest request, HttpServletResponse response,
                                   @RequestParam(defaultValue = "", value = "fnumber") String fnumber,
                                   @RequestParam(defaultValue = "", value = "name") String name,
                                   @RequestParam(defaultValue = "", value = "beginTime") String beginTime,
                                   @RequestParam(defaultValue = "", value = "endTime") String endTime) {
        //获取操作人信息
        User user = (User) request.getSession().getAttribute("user");

        //头部数据
        List<Object> data = new ArrayList<>();
        String head[] = {"单据编号", "业务日期", "参考消息", "审核人", "制单人", "单据状态", "学员", "学员编号", "身份证号码", "车型",
                "结业时间", "发证时间", "结业编号", "手机号码"
        };
        //长度
        Integer length[] = {8500, 5000, 6000, 3000, 3000, 3000, 3000, 6000, 8000, 3000,
                5000, 5000, 5000, 5000};

        List<Recordinentry> recordinentryList = recordinService.selectRecordinXls(fnumber, name, beginTime, endTime, user.getFcompanyid());


        for (Recordinentry recordinentry : recordinentryList) {
            data.add(recordinentry.getFnumber());
            data.add(recordinentry.getFbizdate());
            data.add(recordinentry.getFdescription());
            data.add(recordinentry.getCheckName());
            data.add(recordinentry.getCreateName());
            data.add(stateToString.billsState(recordinentry.getCfbillstate()));
            data.add(recordinentry.getUsername_v());//维修项目
            data.add(recordinentry.getCfstudentno());
            data.add(recordinentry.getCfidcardno());
            data.add(recordinentry.getCfcartype());
            data.add(recordinentry.getCfcfwz());
            data.add(recordinentry.getCfremark());
            data.add(recordinentry.getCfjyzbh());
            data.add(recordinentry.getCfsjhm());
        }

        try {
            //导出Excel
            CommonExport.importExcel(response, "档案入库" + TimeFormat.getNowTime2() + ".xls", "档案入库", data, head, length);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return "redirect:/DrivingSys/queryRecordin/look.action?state=first";
    }

}
